{% extends 'base.twig' %}

{% block breadcrumb %}
	<ol class="breadcrumb">
		<li><a href="/login">Вход</a></li>
		<li class="active">Восстановление пароля</li>
	</ol>
{% endblock %}

{% block head %}
	<script type="text/javascript">
		$(function () {
			$('#rememberForm').ajaxForm({
				dataType: 'json',
				beforeSubmit: function () {
					$.fancybox.showLoading();
				},
				success: function (d) {
					$.fancybox.hideLoading();
					if (d['error'] == 'invalid_email') {
						$('#rememberForm .text-danger').html('Неправильный e-mail!');
						$('#email').css('background-color', '#ffcccc');
						return;
					} else {
						$('#email').css('background-color', '');
					}

					if (d['error'] == 'email_notfound') {
						$('#rememberForm .text-danger').html('Пользователь не найден!');
						$('#email').css('background-color', '#ffcccc');
						return;
					} else {
						$('#email').css('background-color', '');
					}

					$('#rememberDiv').html('<h2>На Ваш e-mail выслан пароль!</h2>');
				}
			})
		});
	</script>
{% endblock %}

{% block content %}
	<div id="rememberDiv">
		<form action="/user/remember" method="post" class="form-horizontal" id="rememberForm">
			<div class="text-danger"></div>
			<div class="form-group">
				<label for="email" class="col-sm-3 control-label">Ваш e-mail:</label>

				<div class="col-sm-9">
					<input class="form-control" name="email" id="email" placeholder="Ваш e-mail">
				</div>
			</div>
			<div class="col-sm-offset-3 col-sm-9">
				<button type="submit" class="btn btn-primary">Восстановить</button>
			</div>
		</form>
	</div>
{% endblock %}